package com.sunny.client.v1;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * @author Sunny
 * @date 2020/2/16
 */
public class RpcClientHandler extends ChannelInboundHandlerAdapter {

    private Object result;
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("Rpc Client connect success!");
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        result = msg;
        System.out.println("客户端接收数据: " + msg);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        cause.printStackTrace();
    }

    public Object getResult() {
        return result;
    }
}
